// 快速排序
let nums = [-2,3,-5,4,6]
var sortArray = function (nums) {
    if(nums.length < 2) return nums
    let  midIndex = Math.floor(nums.length / 2)
    let mid = nums.splice(midIndex,1)
    let left = []
    let right = []
    for (let i = 0; i < nums.length; i++) {
       if(nums[i] < mid) left.push(nums[i])
       else right.push(nums[i])
    }
    return sortArray(left).concat([mid],sortArray(right))
};
console.log(sortArray(nums));